home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1994 #2 / Monster Media No. 2 (Monster Media)(1994).ISO / prog_bas / mquery.zip / MJOIN.FRM < prev    next >
Text File  |  1994-05-24  |  8KB  |  261 lines

  1. VERSION 2.00
  2. Begin Form fJoin 
  3.    BackColor       =   &H00C0C0C0&
  4.    BorderStyle     =   1  'Fixed Single
  5.    Caption         =   "Join Tables"
  6.    ClientHeight    =   3900
  7.    ClientLeft      =   2580
  8.    ClientTop       =   2250
  9.    ClientWidth     =   7620
  10.    ControlBox      =   0   'False
  11.    Height          =   4305
  12.    Left            =   2520
  13.    LinkTopic       =   "Form1"
  14.    MaxButton       =   0   'False
  15.    MinButton       =   0   'False
  16.    ScaleHeight     =   3900
  17.    ScaleWidth      =   7620
  18.    Top             =   1905
  19.    Width           =   7740
  20.    Begin Frame Frame1 
  21.       BackColor       =   &H00C0C0C0&
  22.       Caption         =   "Select type of Join"
  23.       Height          =   2175
  24.       Left            =   120
  25.       TabIndex        =   8
  26.       Top             =   1560
  27.       Width           =   7335
  28.       Begin OptionButton rRightjoin 
  29.          BackColor       =   &H00C0C0C0&
  30.          Caption         =   "Option1"
  31.          Height          =   255
  32.          Left            =   120
  33.          TabIndex        =   14
  34.          Top             =   1440
  35.          Width           =   255
  36.       End
  37.       Begin OptionButton rleftjoin 
  38.          BackColor       =   &H00C0C0C0&
  39.          Caption         =   "Option1"
  40.          Height          =   255
  41.          Left            =   120
  42.          TabIndex        =   13
  43.          Top             =   840
  44.          Width           =   255
  45.       End
  46.       Begin OptionButton rEqijoin 
  47.          BackColor       =   &H00C0C0C0&
  48.          Caption         =   "Option1"
  49.          Height          =   255
  50.          Left            =   120
  51.          TabIndex        =   12
  52.          Top             =   360
  53.          Value           =   -1  'True
  54.          Width           =   255
  55.       End
  56.       Begin Label Label3 
  57.          BackColor       =   &H00C0C0C0&
  58.          Caption         =   "Right  Join Include all rows from the right table and only those rows in the left  table where joined fields are equal"
  59.          Height          =   495
  60.          Left            =   600
  61.          TabIndex        =   11
  62.          Top             =   1440
  63.          Width           =   6495
  64.       End
  65.       Begin Label Label2 
  66.          BackColor       =   &H00C0C0C0&
  67.          Caption         =   "Left Join Include all rows from  left table and only those rows in the right table where joined fields are equal"
  68.          Height          =   495
  69.          Left            =   600
  70.          TabIndex        =   10
  71.          Top             =   840
  72.          Width           =   6495
  73.       End
  74.       Begin Label Label1 
  75.          BackColor       =   &H00C0C0C0&
  76.          Caption         =   "Equi-Join Include all rows from both tables where joined fields are equal."
  77.          Height          =   375
  78.          Left            =   600
  79.          TabIndex        =   9
  80.          Top             =   360
  81.          Width           =   6495
  82.       End
  83.    End
  84.    Begin CommandButton ClearJoinsButton 
  85.       BackColor       =   &H00C0C0C0&
  86.       Caption         =   "C&lear All Joins"
  87.       Height          =   375
  88.       Left            =   5880
  89.       TabIndex        =   7
  90.       Top             =   720
  91.       Width           =   1575
  92.    End
  93.    Begin CommandButton CloseButton 
  94.       BackColor       =   &H00C0C0C0&
  95.       Cancel          =   -1  'True
  96.       Caption         =   "&Close"
  97.       Height          =   375
  98.       Left            =   5880
  99.       TabIndex        =   6
  100.       Top             =   1200
  101.       Width           =   1575
  102.    End
  103.    Begin ListBox cFieldList2 
  104.       BackColor       =   &H00FFFFFF&
  105.       Height          =   1200
  106.       Left            =   3960
  107.       TabIndex        =   4
  108.       Tag             =   "OL"
  109.       Top             =   240
  110.       Width           =   1815
  111.    End
  112.    Begin ListBox cFieldList1 
  113.       BackColor       =   &H00FFFFFF&
  114.       Height          =   1200
  115.       Left            =   2040
  116.       TabIndex        =   3
  117.       Tag             =   "OL"
  118.       Top             =   240
  119.       Width           =   1815
  120.    End
  121.    Begin CommandButton AddJoinButton 
  122.       BackColor       =   &H00C0C0C0&
  123.       Caption         =   "&Add Join to Query"
  124.       Enabled         =   0   'False
  125.       Height          =   375
  126.       Left            =   5880
  127.       TabIndex        =   1
  128.       Top             =   240
  129.       Width           =   1575
  130.    End
  131.    Begin ListBox cTableList 
  132.       BackColor       =   &H00FFFFFF&
  133.       Height          =   1200
  134.       Left            =   120
  135.       MultiSelect     =   1  'Simple
  136.       TabIndex        =   0
  137.       Tag             =   "OL"
  138.       Top             =   240
  139.       Width           =   1815
  140.    End
  141.    Begin Label FieldsLabel 
  142.       Alignment       =   2  'Center
  143.       BackColor       =   &H00C0C0C0&
  144.       Caption         =   "Select Fields to Join Selected Tables on:"
  145.       Height          =   192
  146.       Left            =   2040
  147.       TabIndex        =   5
  148.       Top             =   0
  149.       Width           =   3732
  150.    End
  151.    Begin Label TableListLabel 
  152.       BackColor       =   &H00C0C0C0&
  153.       Caption         =   "Select Table Pair:"
  154.       Height          =   192
  155.       Left            =   120
  156.       TabIndex        =   2
  157.       Top             =   0
  158.       Width           =   1812
  159.    End
  160. End
  161. Option Explicit
  162. Dim FTbl1 As String
  163. Dim FTbl2 As String
  164.  
  165. Sub AddJoinButton_Click ()
  166.   Dim i As Integer
  167.  
  168.    ' check for type of join
  169.  
  170.     Select Case reqijoin.Value ' equi join
  171.     Case True
  172.     fQuery.cJoinFields.AddItem FTbl1 + " INNER JOIN " + FTbl2 + " ON " + FTbl1 + "." + "[" + cFieldList1 + "]" + "=" + FTbl2 + "." + "[" + cFieldList2 + "]"
  173.     End Select
  174.  
  175.     Select Case rleftjoin.Value ' left join
  176.     Case True
  177.     fQuery.cJoinFields.AddItem FTbl1 + " LEFT JOIN " + FTbl2 + " ON " + FTbl1 + "." + "[" + cFieldList1 + "]" + "=" + FTbl2 + "." + "[" + cFieldList2 + "]"
  178.     End Select
  179.  
  180.     Select Case rRightjoin.Value ' right join
  181.     Case True
  182.     fQuery.cJoinFields.AddItem FTbl1 + " RIGHT JOIN " + FTbl2 + " ON " + FTbl1 + "." + "[" + cFieldList1 + "]" + "=" + FTbl2 + "." + "[" + cFieldList2 + "]"
  183.     End Select
  184.  
  185.   For i = 0 To cTableList.ListCount - 1
  186.     cTableList.Selected(i) = False
  187.   Next
  188. End Sub
  189.  
  190. Sub cFieldList1_Click ()
  191.   If cFieldList2 <> "" Then
  192.     AddJoinButton.Enabled = True
  193.   End If
  194. End Sub
  195.  
  196. Sub cFieldList2_Click ()
  197.   If cFieldList1 <> "" Then
  198.     AddJoinButton.Enabled = True
  199.   End If
  200. End Sub
  201.  
  202. Sub ClearJoinsButton_Click ()
  203.   fQuery.cJoinFields.Clear
  204. End Sub
  205.  
  206. Sub CloseButton_Click ()
  207.   Unload Me
  208. End Sub
  209.  
  210. Sub cTableList_Click ()
  211.   Dim i As Integer
  212.   Dim t As TableDef
  213.  
  214.   FTbl1 = ""
  215.   FTbl2 = ""
  216.   cFieldList1.Clear
  217.   cFieldList2.Clear
  218.  
  219.   For i = 0 To cTableList.ListCount - 1
  220.     If cTableList.Selected(i) Then
  221.       If FTbl1 = "" Then
  222.         FTbl1 = cTableList.List(i)
  223.       Else
  224.         FTbl2 = cTableList.List(i)
  225.         Exit For
  226.       End If
  227.     End If
  228.   Next
  229.   
  230.   If FTbl2 = "" Then Exit Sub   'only one table selected
  231.  
  232.   Set t = gCurrentDB.TableDefs(FTbl1)
  233.   For i = 0 To t.Fields.Count - 1
  234.     cFieldList1.AddItem t.Fields(i).Name
  235.   Next
  236.  
  237.   Set t = gCurrentDB.TableDefs(FTbl2)
  238.   For i = 0 To t.Fields.Count - 1
  239.     cFieldList2.AddItem t.Fields(i).Name
  240.   Next
  241.  
  242. End Sub
  243.  
  244. Sub Form_Load ()
  245.   Dim i As Integer
  246.  
  247.   For i = 0 To fQuery.cTableList.ListCount - 1
  248.     If fQuery.cTableList.Selected(i) Then
  249.       cTableList.AddItem fQuery.cTableList.List(i)
  250.     End If
  251.   Next
  252.   'Top = VDMDI.Top + fQuery.Top + fQuery.cCriteria.Top + 1300
  253.   'Left = fQuery.Left + 1500
  254.   
  255. End Sub
  256.  
  257. Sub Form_Paint ()
  258.   Outlines Me
  259. End Sub
  260.  
  261.